home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
games
/
ippon
/
source.lzh
/
FuncEnemy
/
round4.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-07-07
|
6KB
|
282 lines
/* round4.c 回転4枚羽 */
#include <xsp2lib.h>
#include "../main.h"
#include "../player.h"
#include "../shot.h"
#include "../enemy.h"
#include "../eshot.h"
#include "../effect.h"
#include "../psearch.h"
#include "../sound.h"
#define PALET_MAIN 0x0500
#define HP_0 15
#define SHOT_SPEED 7
/* 関数プロトタイプ宣言 */
static short EnemyMoveRound4 (ENEMY *);
static void EnemyFreeRound4 (ENEMY *);
enum {
APPEAR_LEFT = 0, APPEAR_RIGHT
};
/* 初期化ルーチン */
void EnemyAllocRound4 (ENEMY * p)
{
if (SHORT_LX < 144) {
p->m_work2 = APPEAR_LEFT;
p->vx = 1 * 65536;
} else {
p->m_work2 = APPEAR_RIGHT;
p->vx = -1 * 65536;
}
p->vy = 2 * 65536;
p->pt = obj_round4 + 25;
p->info = PALET_MAIN | PRIORITY_BOSS;
p->hit_sx = 20;
p->hit_sy = 16;
p->hp = HP_0;
p->damage = 0;
p->flash = 0;
p->damage_mode = DAMAGE_PIERCE;
p->func_enemy_move = EnemyMoveRound4;
p->func_enemy_free = EnemyFreeRound4;
/* コア関連 */
p->core_pt = sp_core;
p->core_info = PALET_CORE_RED | PRIORITY_BOSS;
p->m_work = 0;
p->m_work3 = 0; /* 回転角(8+8bit 固定小数点) */
p->m_work4 = 2 << 8; /* 回転角の速度 */
}
/* 移動ルーチン */
/* 返り値:非0なら消去 */
static short EnemyMoveRound4 (ENEMY * p)
{
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
p->x = (p->lx += p->vx) >> 16;
p->y = (p->ly += p->vy) >> 16;
switch (p->m_work) {
case 0:
if (SHORT_LY > 64)
p->m_work++;
/* 回転処理 */
p->m_work3 += p->m_work4;
if (p->m_work3 > (8 << 8))
p->m_work3 -= (8 << 8);
p->pt = obj_round4 + 25 + *(char *) (&p->m_work3);
break;
case 1:
/* 移動処理 */
if (p->m_work2 == APPEAR_LEFT) {
if (p->vx > 0)
p->vx -= 4096;
else
p->vx = 0;
} else {
if (p->vx < 0)
p->vx += 4096;
else
p->vx = 0;
}
if (SHORT_VY > 0)
p->vy -= 4096;
/* 回転処理 */
p->m_work3 += p->m_work4;
if (p->m_work4 > 32)
p->m_work4 -= 8;
p->pt = obj_round4 + 25 + *(char *) (&p->m_work3);
if (p->m_work3 > (8 << 8)) {
p->m_work3 -= (8 << 8);
p->pt = obj_round4 + 25;
if (p->m_work4 < 192) {
/* 回転数が落ちてほとんど停止したら次の段階へ移行 */
p->m_work++;
p->vx = 0;
p->pt = obj_round4;
}
}
break;
case 2: /* 羽を開く */
if (SHORT_VY > 0)
p->vy -= 4096;
p->pt++;
if (p->pt == obj_round4 + 13)
SoundSetSE (SE_LOCK); /* 「がちゃん」という効果音を鳴らす */
/* 攻撃処理 */
#define SPEED_SHOT2 8
if (p->pt == obj_round4 + 14) {
char a = psearch (p->x, p->y);
EshotAlloc (ESHOT_NRG04, p->x - 20, p->y - 20, SPEED_SHOT2, a, 0);
EshotAlloc (ESHOT_NRG04, p->x + 20, p->y - 20, SPEED_SHOT2, a, 0);
EshotAlloc (ESHOT_NRG04, p->x - 20, p->y + 20, SPEED_SHOT2, a, 0);
EshotAlloc (ESHOT_NRG04, p->x + 20, p->y + 20, SPEED_SHOT2, a, 0);
EshotAlloc (ESHOT_NRG03, p->x - 16, p->y - 16, SPEED_SHOT2, a, 0);
EshotAlloc (ESHOT_NRG03, p->x + 16, p->y - 16, SPEED_SHOT2, a, 0);
EshotAlloc (ESHOT_NRG03, p->x - 16, p->y + 16, SPEED_SHOT2, a, 0);
EshotAlloc (ESHOT_NRG03, p->x + 16, p->y + 16, SPEED_SHOT2, a, 0);
SoundSetSE (SE_ESHOT); /* 敵ショット音 */
}
if (p->pt > obj_round4 + 23) {
p->m_work++;
p->s_work = p->s_work2 = p->s_work3 = 0;
p->m_work3 = 0; /* 回転角(8+8bit固定小数点) */
p->m_work4 = 16; /* 回転角加速度 */
}
break;
case 3: /* 開いた状態で回転 */
/* 移動処理 */
if (p->m_work2 == APPEAR_LEFT) {
if (p->vx < 65536)
p->vx += 4096;
} else {
if (p->vx > -65536)
p->vx -= 4096;
}
if (p->vy < 65536)
p->vy += 4096;
/* 回転処理 */
p->m_work3 += p->m_work4;
if (p->m_work4 < 256)
p->m_work4 += 4;
else
p->m_work4 = 256;
if (p->m_work3 > (8 << 8))
p->m_work3 -= (8 << 8);
p->pt = obj_round4 + 25 + 9 + *(char *) (&p->m_work3);
#define SPEED_SHOT3 8
#define INTERVAL2_1 27
/* 攻撃処理 */
#if 0
switch (p->s_work++) {
case 1:
p->s_angle = psearch (p->x, p->y);
/* 右か左か */
if (SHORT_LX < player->x)
p->s_angle2 = 8;
else
p->s_angle2 = -8;
case 1 + INTERVAL2_1 * 1:
case 1 + INTERVAL2_1 * 2:
EshotAlloc (ESHOT_NRG14N, p->x, p->y, SPEED_SHOT3, p->s_angle += p->s_angle2, 0);
break;
case 1 + INTERVAL2_1 * 2 + 1:
p->m_work++;
break;
default:
break;
}
#else
if (p->s_work++ == INTERVAL2_1 * 2 + 1)
p->m_work++;
#endif
break;
case 4: /* 上昇して逃げる */
/* 移動処理 */
if (p->m_work2 == APPEAR_LEFT) {
if (p->vx > -65536)
p->vx -= 4096;
} else {
if (p->vx < 65536)
p->vx += 4096;
}
if (p->vy > -65536)
p->vy -= 4096;
/* 回転処理 */
p->m_work3 += p->m_work4;
if (p->m_work4 < 256)
p->m_work4 += 4;
else
p->m_work4 = 256;
if (p->m_work3 > (8 << 8))
p->m_work3 -= (8 << 8);
p->pt = obj_round4 + 25 + 9 + *(char *) (&p->m_work3);
/* 画面外に出たら消去 */
if (SHORT_LY < -48)
return (-1); /* 消去 */
break;
}
/* もし前回ダメージを受けたなら */
if (p->damage) {
p->hp -= p->damage;
p->damage = 0;
SoundSetSE (SE_DAMAGE); /* 敵ダメージ音 */
/* 白(or赤)フラッシュ処理 */
if (p->info == (PALET_MAIN | PRIORITY_BOSS)) {
if (p->hp < HP_PALET_RED)
p->info = PALET_RED | PRIORITY_BOSS;
else
p->info = PALET_DAMAGE | PRIORITY_BOSS;
} else {
p->info = PALET_MAIN | PRIORITY_BOSS;
}
/* 耐久力が0以下なら消去 */
if (p->hp <= 0) {
EffectAlloc (EFFECT_EXPL, 0, p->x, p->y); /* 爆発パターンを出現させる */
EffectAlloc (EFFECT_POINTS, POINTS_1500, p->x, p->y); /* 得点を出現させる */
SoundSetSE (SE_EXPL_M); /* 中ボス爆発音 */
return (-1);
}
} else {
/* 耐久力が少なくなったら赤フラッシュ */
if ((p->flash++ > TIMER_FLASH_RED) && (p->hp < HP_PALET_RED)) {
p->info = PALET_RED | PRIORITY_BOSS;
if (p->flash > TIMER_FLASH_NORMAL)
p->flash = 0;
} else {
p->info = PALET_MAIN | PRIORITY_BOSS;
}
}
xobj_set_st (p); /* 表示 */
/* コアの表示 */
p->core_x = p->x - 8;
p->core_y = p->y - 8;
xsp_set_st (&(p->core_x));
return (0);
}
/* 消去ルーチン */
static void EnemyFreeRound4 (ENEMY * p)
{
/* 刺さったショットの処理 */
if ((p->shot) && (p->shot->enemy) && (p->shot->enemy == p))
p->shot->status = SHOT_STATUS_NON;
}